4. Objects

All generic features of Objects are inherited from the object base class. These include title, size, type, status of the Object and all chores of dragging, deleting, redrawing of Objects on the screen, all necessary for this pointers and the memory management. The following data members and methods are public in object class and are inherited by all Objects.

* Stack of Objects. This is the connected list of POPUP and on-the- screen PERM objects. Objects are pushed in this stack by Virtual Panels core when they are declared in the run-time order. Only PERM and POPUP Objects are pushed in the stack. The stack can be used only by the MASTER button system.

* Active Object. You can rearrange the Stack of Objects and put the desired Object on the top of the stack calling the method MkActive() (look at the example 2.6.1 or example below). This makes the Object active. When the Object is active it can be manipulated from console while the program is in Virtual Panels Loop. The object can be dragged, removed and so on.

* Removing and Adding Objects. When the Object is removed (method Remove(), what means that the Object is cleared out from the screen) it remains in the stack if it is POPUP or removed from the stack if it is PERM. If the Object is not in the stack when MkActive() is called, it is pushed in the stack.

* List of Objects. There is connected list of all Objects for internal use by Virtual Panels core. In this list Objects are added by their constructors and extracted by their destructors. The List of Objects is not connected with the button system.

Data members:

int x0,y0,xmax,ymax; // location of the Object
int xx0,yy0,xxmax,yymax; // versatile location of the Object

Size and location of the Object. May be used to determine the space taken up by the Object on the screen (useful when you are disposing Objects on the screen). These data members are read-only.

unsigned OnScreen, Active;

Read-only status data. If the Object is currently on the screen then the status OnScreen is TRUE (non-zero), otherwise it is FALSE (zero). The status Active is TRUE if the Object is active and is FALSE otherwise. When the Object is active it is on the top of the Stack of Objects. The status data have no sense for FIXED Objects.

Methods:

virtual void Paint(void)=0;

Paints the Object on the screen. This is a virtual method specific for each Object.

void GetXY(int *x0,int *y0,int *xmax,int *ymax);
void GetXXYY(int *xx0,int *yy0,int *xxmax,int *yymax);

These methods give you another way to get the location of the Object. When there is an extensive use of the corresponding data members it is more effective for size and speed of program to use the local variables instead of the data members.

void Remove(void);

Removes POPUP or PERM Object from the screen and restores underlying image. Also removes PERM Object from the Stack of Objects.

void MkActive(void);

Makes the Object active, what means that the Object is put on the top of the Stack of Objects. When the Object is active it can be manipulated from console while program is in Virtual Panels Loop. If the Object is not in the stack when MkActive() is called, it is pushed in the stack.

void MovetoXY(int x0,int y0);

Changes the Objects location on the screen so, that its LEFT-TOP corner will be at (x0,y0) (in VGA pixels). May be used to drag the Object from the program. The following is the example of dragging of the object SomeObject:

SomeObject.Remove();    // remove Object from the current place
SomeObject.MovetoXY( newX0, newY0); // change location
SomeObject.Paint();     // paint it in the new location
SomeObject.MkActive();  // put it on the top of the stack

The following methods are static:

void object::NextPERM(void);

Makes active the next PERM Object in the Stack of Objects and repaints it over other Objects on the screen. Usually this can be done from console by striking F6 . This method allows you to do this from the program.

void object::RepaintScr(void);

Repaints the Dragging area. Scans the Stack of Objects and paints only PERM Objects with status OnScreen==TRUE, calling their paint procedures. The Object closest to the top of the stack is painted last. May be used to reclaim the Dragging area when it is corrupted.

int object::SaveCnfg(char *cnffilename);
returns:
0 if OK,
-1 if cannot write to or create configuration file
-2 if no PERM or POPUP objects currently exist

Saves configuration of PERM and POPUP objects in cnffilename.

int object::LoadCnfg(char *cnffilename);
returns:
0 if OK,
-1 if cnffilename doesn't exist
-2 if no PERM or POPUP objects currently exit
-3 if keyword doesn't match

Restores configuration of PERM and POPUP objects from cnffilename.

By configuration we mean locations and status data of objects and the content of the Stack of Objects. Save the configuration before leaving the program and then you can restore in the next session the last changes you have made on the Dragging area.



Subsections